package com.itheima.d1_exception_javac;

/**
 * 运行时才会产生的异常，在编译阶段不会报错，异常继承RuntimeException
 */
public class demo1 {
    public static void main(String[] args) {
        System.out.println("starting ----");

        /** 1.数组越界：ArrayIndexOutOfBoundException */
        int[] arr = {1,2,3};
        System.out.println(arr[1]);
        System.out.println(arr[3]);

         /** 2.空指针异常：NullPointerException。直接输出没问题，调用空指针变量会报错*/
        String name = null;
        System.out.println(name);
        System.out.println(name.length());
         /** 3.类型转换异常：ClassCastException。*/
        Object o = 23;
        String s = (String)o;
         /** 4.数学操作异常：ArithmeticException。*/
        int n= 10/0;
         /** 5.数字转换异常：NumberFormatException。*/
        String number = "23abbb";
        Integer it = Integer.valueOf(number);
        System.out.println(it+1);
    }



}
